<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "专厅管理";
  var objName="session";
  var currentObjId = "";
</script>
<script type="text/javascript" src="${ctx}/js/zbxupload.js"></script> 
<title>专厅管理-${sysName }</title>
</head>
<body class="home-template2">
<!-- 正文开始 -->
<div class="searchForm"><form id="myList_form">
	<input type="hidden" name="page"  value="1">
	<input type="hidden" name="rows"  value="7">
	<input type="hidden" name="sessionType" id="sessionType" value="1">
	专厅名称：<input type="text" name="sessionName"  value="" /> 
	<a class="easyui-linkbutton"  iconCls="icon-search" onclick="myListSearch();">查询</a>
	<a class="easyui-linkbutton"  onclick="clearFormById('myList_form');">清空</a>
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen();">增加新的专厅</a>
</form></div>
<table id="myList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='25%'>专厅名称</th>
		<th width='10%'>竞价方式</th>
		<th width='10%'>状态</th>	
		<th width='20%'>创建时间</th>		
		<th width='15%' class='th_center'>操作</th>
	</tr>
</table>
<div id="myList_page" class="page"></div>
<script type="text/template" id="myList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=bill_<?=rows[i].billid?>>
			<td title=<?=rows[i].sessionName?>><?=strUtil.subStr(rows[i].sessionName,25)?></td>
			<td style="text-align:center;"><?=bidModeText(rows[i].sessionMode)?></td>
			<td style="text-align:center;"><?=sessionStatusText(rows[i].status)?></td>
			<td style="text-align:center;"><?=rows[i].createTime?></td>
			<td>
				<a class="mybutton"  onclick="view('<?=rows[i].sessionId?>');">专厅管理</a> 
                <?if(rows[i].status==0 ){?>
				|| <a class="mybutton"  onclick="del('<?=rows[i].sessionId?>');">删除</a>
				<?}?>
			</td>
		</tr>
   <?}?>  		
</script>
<!-- 正文结束 -->
<%//@ include file="/common/top.jsp" %>
<div class="easyui-dialog" id="add_window" title="增加专厅" closed="true" modal="true" style="width:900px;height:550px;">
<form id="addForm" onsubmit="">
<table class="info" cellspacing="1" cellpadding="0">
	<input type="hidden" name="sessionId" id="sessionId" value="">
	<input type="hidden" name="sessionType" value="1">
	<input type="hidden" name="ifBidDyn" value="T">
	<input type="hidden" name="serialCtrl" value="F">
	<input type="hidden" name="status" id="status" value="0">
	<input type="hidden" name="orgEname" value="${loginUser.orgEname}">
	<input type="hidden" name="orgCname" value="${loginUser.orgCname}">
	<input type="hidden" name="direction" value="T">
	<input type="hidden" name="ifGroup" value="F">
	<tr>
		<th>专厅名称：<font color="red">*</font></th>

		<td colspan="3"><input type="text" name="sessionName" id="sessionName" class="easyui-validatebox validatebox-text" 
			validtype="length[1,50]"	required="true"  missingMessage="请输入专厅名称"  maxlength="80"
				invalidMessage="最多可输入50中文字符"  title="最多可输入50中文字符"  size="120" value=""/>
		</td>

	</tr>
	<tr>
		<th>竞价方式：<font color="red">*</font></th>
		<td colspan="3">
			<input type="radio" name="sessionMode"  value="1" checked/>正向多次竞价&nbsp;
			<input type="radio" name="sessionMode"  value="2" />反向多次竞价&nbsp;
		</td>
	</tr>
	<tr>
	    <th>报价服务器：<font color="red">*</font></th>
		<td><select  id="bjServerStr" name="bjServerStr" /></select></td>
		<th>专厅图片：</th>
		<td>
		<div msg="第1组">
		  <img id="fileUpText_1_showImg" src="${ctx}/images/def.jpg" style="height:40px;" />
		  <label onclick="addUploadFile(1);" for="uploadFileInput" class="fDef_Btn" >选择文件</label>
		  <label id="fileUpText_1_subbtn" onclick="$.zbxupload.uploadSubmit(this);" style='display:none;' class="fDef_Btnse" >开始上传</label>
		  <input id="fileUpText_1" name="picUrl" type="hidden" class="fDef_Input" > <!-- 此元素的name="attaUrl" 对照修改后台属性，以备入库 -->
		  <label id="fileUpText_1_msg"></label> <!--不要信息提示，就去掉此 -->
		</div>
         </td>
	</tr>
	<tr>
		<th>保证金控制方式：<font color="red">*</font></th>
		<td colspan="3">
			<input type="radio" name="bailCtrl"  value="1" checked="true" onclick="bcontrol(1);"/>1.活动固定保证金制。
			<input type="radio" name="bailCtrl"  value="2" onclick="bcontrol(2);"/>2.每个标的收取固定保证金制。
			<input type="radio" name="bailCtrl"  value="3" onclick="bcontrol(3);"/>3.专厅不设保证金，按设置的保证金比例扣除竞买人的保证金。
		</td>
	</tr>
	<tr id="tr_bailFix" >
		<th>专厅保证金：</th>
		<td colspan="3">
			<input type="text" name="bailFix" id="bailFix" maxlength="20"  class="easyui-validatebox validatebox-text" 
			validtype="number"	  invalidMessage="必须为非负的数字"  title="专厅保证金" />
			<font id="bailFix_desc" color="red"></font>
		</td>
	</tr>
	<tr id="tr_bailBl" style="display:none;">
		<th>保证金比例：</th>
		<td colspan="3">
			<input type="text" name="bailRate" id="bailRate" maxlength="20" class="easyui-validatebox validatebox-text"
			 validtype="number" invalidMessage="必须为非负的数字"/>%
			<font id="bailRate_desc" color="red"></font>
		</td>
	</tr>
	<tr>
	   <th>竞价开始时间：<font color="red">*</font></th>
		<td colspan="3"><input type="hidden" name="openTime" id="openTime" value=""  /> 
				<select id="openTime_y" class="myDate"></select>年
				<select id="openTime_m" class="myDate"></select>月
				<select id="openTime_d" class="myDate"></select>日
				<select id="openTime_hh" class="myTime"></select>时
				<select id="openTime_mm" class="myTime"></select>分
				<select id="openTime_ss" class="myTime"></select>秒
		
		</td>
	</tr>
	<tr >
		<th>自由报价期：<font color="red">*</font></th>
		<td><input type="text" name="firstTime"  id="firstTime" value="5" size="10" maxlength="4" validtype="number"  class="easyui-validatebox validatebox-text" 
				   invalidMessage="必须为1~4位长的非负数字"  title="自由报价期" onblur="if(this.value=='') {this.value='5';}"/>（天） </td>
	    <th>限时报价周期：<font color="red">*</font></th>
		<td><input type="text" name="limitTime" id="limitTime"  value="60" size="10" maxlength="4" validtype="number"  class="easyui-validatebox validatebox-text" 
			   invalidMessage="必须为1~4位长的非负数字"  title="限时报价周期"  onblur="if(this.value=='') {this.value='60';}"  />（秒）</td>
	</tr>
	<tr>
		<th>专厅介绍：<font color="red">*</font></th>
		<td  colspan="3"><textarea cols=80 rows=4 id="infoDesc" name="infoDesc" maxlength="110"  class="easyui-validatebox validatebox-text" 
			validtype="length[1,100]"	required="true"  missingMessage="请输入专厅介绍"  
				invalidMessage="最多可输入100中文字符"  title="最多可输入100中文字符" ></textarea></td>
	</tr>
	<tr>
		<td colspan="4" style="text-align:center;">
			<a class="easyui-linkbutton" id="addButton" iconCls="icon-add" onclick="add();">增加</a>
			<a class="easyui-linkbutton" id="editButton" iconCls="icon-add" onclick="edit();">修改</a>
		</td>
	</tr>
</table>
</form>
</div>

<!-- 附件上传iframe元素 -->
<iframe name='uploadIframe' id='uploadIframe' frameborder='0' height='0' width='0'></iframe>
<div id="uploadIframeDefDiv" style="height:0px;" ></div>

</body>
</html>

<script>
function bcontrol(bn){
	var btxt ="";
	if(bn==2) btxt = "这里指的是每个标的需交纳的保证金数！";
	if(bn==3) btxt = "在选择3的情况下，不需要设置此项！";
	$("#bailFix_desc").html(btxt);
}

//打开查看页面
function view(sessionId){
	//alert(sessionId);
	window.location.href= ctx+spaceDomain+objName+"/view?sessionId="+sessionId;
}
//保证金设置提示信息
function bcontrol(bn){
	var btxt ="";
	if(bn==2 || bn==1){ 
		$("#tr_bailFix").show();
		$("#tr_bailBl").hide();
	}
	if(bn==3){
		$("#tr_bailFix").hide();
		$("#tr_bailBl").show();
	}
	//$("#bailFix_desc").html(btxt);
}
//查询提交
function myListSearch(){
	searchSubmit(objName,"myList");
}

//===================新增===================
//新增： 打开新增窗口
function addOPen(){
   // clearFormById("addForm");
   // $("#limitTime").val(60);
    //$("#sessionMode").combobox("setValue","");//初始值“---请选择---”被clear掉了，所以需要加此行代码
    
	//本业务系统下拉数据
	//jsonDataSelect("bjServerStr","server","");
	
    //clearInputByFormId("addForm");
	$("#add_window").dialog('open');
	$("#addButton").show();
	$("#editButton").hide();
}

//新增一条记录
function add(){
	setMyTime('openTime');
    var bj = $('#bjServerStr').val();//var bj = $('#addForm').find("input[name='bjServerStr'][type='hidden']").val();
    if(bj==""||bj==null){
       alert("报价服务器不能为空！");
       return;
    }
    var  sessionModeVal = $("input[name='sessionMode']:checked").val();
    //alert(sessionModeVal);
    if(sessionModeVal=="1"){
    	$('#addForm').find("input[name='direction']").val("T");
    }else{
    	$('#addForm').find("input[name='direction']").val("F");
    }
    var  bailCtrl = $("input[name='bailCtrl']:checked").val();
    if(bailCtrl == "1" || bailCtrl=="2"){
     if($("#bailFix").val()==null ||$("#bailFix").val()==""){
        alert("专厅保证金不能为空！");
        return;
     }
     if(isNaN($("#bailFix").val())){
		alert("保证金值不正确，请输入正确的数字！");
		return
	 }
     if($("#bailFix").val()==0){
     	alert("专厅保证金不能为0！");
        return;
     }
    }else if(bailCtrl == "3"){
     if($("#bailRate").val()==null ||$("#bailRate").val()==""){
        alert("保证金比例不能为空！");
        return;
     }
     if(isNaN($("#bailRate").val())){
		alert("保证金比例值不正确，请输入正确的数字！");
		return
	 }
     if($("#bailRate").val()==0){
     	alert("保证金比例不能为0！");
        return;
     }
     if($("#bailRate").val()>100){
     	alert("请输入正确的保证金比例值！");
        return;
     }
    }
    var limitTime = $('#limitTime').val();
	if(limitTime == 0){
		alert("限时报价周期值不能为0！");
		return;
	}
	var firstTime = $('#firstTime').val();
	if(firstTime == 0){
		alert("自由报价期值不能为0！");
		return;
	}
	addSubmit(objName,'addForm');	
}
//新增后回调方法
function addCallBack(flag,msg,objName){
	if(flag=="T"){
		myListSearch();
	}else{
		alert(msg);
	}
	$("#add_window").dialog('close');
	
}

//===================更新===================
//打开更新页面
function editOpen(objId){
    clearFormById("addForm");
    //本业务系统下拉数据
	//jsonDataSelect("bjServerStr","server","");
	jsonDataSelectAjax("bjServerStr","server");
	currentObjId=objId;
	getObj(objName,objId);
	$("#addButton").hide();
	$("#editButton").show();
}

function getCallBack(flag,obj){
	if("T"==flag){
		loadData(obj,"addForm");//此方法对combobox不起作用，故下面单独处理
		//$('#bjServerStr').combobox('setValue',(obj.spare5==null||obj.spare5==undefined)?"":obj.spare5);
		//$('#bjServerStr').val((obj.spare5==null||obj.spare5==undefined)?"":obj.spare5);
		//反显图片
		if(obj!=null && obj.spare3!=undefined && obj.spare3!=null && obj.spare3!=''){
			$("#fileUpText_1_showImg").attr("src",obj.spare3);			
		}
		
		$("#add_window").dialog('open');
	}else{
		alert("查询失败");
	}
}

//更新提交
function edit(){
 editSubmit(objName,currentObjId,"addForm");
}
//更新后回调方法
function editCallBack(flag,objName){
	if(flag=="T"){
		myListSearch();
		clearFormById("addForm");
		$("#add_window").dialog('close');
	}else{
		alert("更新失败！");
	}
	
}

//===================删除===================
//删除
function del(objId){
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}
//删除后回调方法
function delCallBack(flag,objName,msg){
	if(flag=="T"){
		myListSearch();
	}else{
		alert(msg);
	}
}

//==========================================
//初始化加载
$(function(){
	//加载分页列表
	myListSearch();
	createMyTimeOption('openTime');
	var nowd = getNowFormatDate();
	initMyTime('openTime',nowd);
	jsonDataSelectAjax("bjServerStr","server");
	 //数据字典：竞价方式企业经济类型[firstId="jjlx",secondId="city",cateEname="cty",fatherValue="0"(顶级为0),ctx="${ctx}"]
	/**loadDiceOneStep('sessionMode','bidMode',0,'${ctx}');
	var tmp = $('#jjlxFir').combobox('getValue');
	loadSecondStep('jjlxSec','jjlx',tmp,'${ctx}');
	**/
});

//附件上传回调方法
function myBack(){
	
}

</script>

